#pragma once

#include "../CPU.h"

class CDead6800:public CCPU
{
public:
	u16	PC;								//6800 registers
	union
		{
		u16	D;
		struct
			{
			u8		B;
			u8		A;
			} b;
		} acc;
	u16	X,S;
	u8		CC;
	u32	EA;								//effective address
	u32	Cycle;							//cycle counter
	u32	Interrupts;						//pending interrupts
	u32	WaitInterrupt;					//waiting on interrupts
	void	*User;							//user data
	ReadFunc *OpPtr;						//function pointers
	ReadFunc *ReadPtr;
	WriteFunc *WritePtr;
	u8 *OpPages[32];						//32 2k pages
	u8 *ReadPages[32];
	u8 *WritePages[32];
	int Debug;
	u16 SavePC;
protected:
	__inline void Indexed();			//indexed addressing
	__inline void PushS(u8 data);		//push byte onto s stack
	__inline void PushS16(u16 data);	//push word onto s stack
	__inline u8 PullS();
	__inline u16 PullS16();
	virtual void AddCycles(int n);	//add cycles to cycle counter
public:
	CDead6800();
	virtual ~CDead6800();
	virtual void Init();
	virtual void Reset();
	virtual void IRQ();
	virtual void NMI();
	virtual void Step();
	virtual u32 Execute(u32 c);
	virtual void SaveState(CState *s);
	virtual void LoadState(CState *s);
	virtual u8 OpRead(u32 addr);
	virtual u8 Read(u32 addr);
	virtual void Write(u32 addr,u8 data);
	virtual u16 ReadWord(u32 addr);
	virtual void WriteWord(u32 addr,u16 data);
	virtual void SetUser(void *u);
	virtual void SetPage(int p,u8 *d);
	virtual void SetOpPage(int p,u8 *d);
	virtual void SetReadPage(int p,u8 *d);
	virtual void SetWritePage(int p,u8 *d);
	virtual void SetOp(ReadFunc *r);
	virtual void SetRead(ReadFunc *r);
	virtual void SetWrite(WriteFunc *w);
	virtual u32 Disassemble(char *dest,u32 p);
	virtual char *GenerateRegNames(char *dest);
	virtual char *GenerateRegData(char *dest);
	virtual u32 GetPC();
	virtual u32 GetCycle();
};
